﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MethodWorx.CMS.Workflow
{
    public class StepExecutionResult
    {
        public int ExitBranch { get; set; }
        public bool WorkflowCompleted { get; set; }
        public bool StepCompleted { get; set; }
        public string Message { get; set; }
        public object Output { get; set; }
        public Action OnFinish { get; set; }

        public static StepExecutionResult Ok()
        {
            return Ok(null, 0);
        }
        public static StepExecutionResult Ok(object output)
        {
            return Ok(output, 0);
        }

        public static StepExecutionResult Finish(Action onFinish)
        {
            return new StepExecutionResult()
                       {
                           OnFinish = onFinish
                       };
        }

        public static StepExecutionResult Ok(int exitBranch)
        {
            return Ok(null, exitBranch);
        }

        public static StepExecutionResult Ok(object output, int exitBranch)
        {
            return new StepExecutionResult()
            {
                ExitBranch = exitBranch,
                StepCompleted = true,
                Output = output
            };
        }

        public static StepExecutionResult Error(string message)
        {
            return new StepExecutionResult()
            {
                ExitBranch = -1,
                Message = message,
                StepCompleted = true
            };
        }
    }
}
